from common import register_api
from .melon import MelonApi, updateLemonById, deleteLemonById, batch_remove_melon


def register_melons_api(api_bp):
    register_api(MelonApi, 'melons_api', '/melons/melon', pk='_id', app=api_bp)
    # 添加路由函数：根据id删除
    api_bp.add_url_rule('/melons/melon/<int:_id>',
                        view_func=updateLemonById,
                        methods=['PUT'])
    # 根据id删除
    api_bp.add_url_rule('/melons/melon/<int:_id>',
                        view_func=deleteLemonById,
                        methods=['DELETE'])
    # 批量删除
    api_bp.add_url_rule('/melons/melon/remove',
                        view_func=batch_remove_melon,
                        methods=['DELETE'])